from flask import current_app
from flask import session
from flask import g
from info.models import User


def do_index_class(num):
    if num==1:
        return 'first'
    elif num==2:
        return 'second'
    elif num==3:
        return 'third'
    else:
        return ''


def user_login_data(view_func):
    def wrapper(*args, **kwargs):
        user_id = session.get('user_id')
        user=None
        try:
            user = User.query.get(user_id)
        except Exception as e:
            current_app.logger.error(e)

        g.user = user
        return view_func(*args, **kwargs)
    return wrapper
